# 启用测试
enable_testing()

# 检查目录是否存在
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR})
    # 包含目录
    include_directories(
        ${CMAKE_CURRENT_SOURCE_DIR}/inc
        ${CMAKE_SOURCE_DIR}/lib/inc
        ${EIGEN3_INCLUDE_DIRS}
    )
    
    # 源文件
    file(GLOB TEST_SOURCES 
        "src/*.cpp"
        "src/eigen/*.cpp"
        "src/vector/*.cpp"
        "src/tools/*.cpp"
        "src/core/*.cpp"
        "src/autograd/*.cpp"
    )
    
    # 创建测试可执行文件
    add_executable(test_program ${TEST_SOURCES})
    
    # 链接库
    find_package(fmt REQUIRED)
    target_link_libraries(test_program learn_deep_learning fmt::fmt)
    
    # 添加测试
    add_test(NAME test_program COMMAND test_program)

    # 安装
    install(TARGETS test_program
        RUNTIME DESTINATION bin
    )
endif()